//
//  PCDApiSetupPassword.m
//  PCDBankSix
//
//  Created by 冀银开发 on 2024/1/23.
//

#import "PCDApiSetupPassword.h"
#import "PCDQueryLoginViewController.h"
#import "YTForgetPWDController.h"
#import "PCDLoginController.h"

@implementation PCDApiSetupPassword

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback
{
    NSDictionary *dict = (NSDictionary *)data;
    UIViewController * vc = context.viewController;
     
    PCDLoginSession *loginSession = [PCDUtil loginSession];
    
    NSDictionary *userInfo = dict[@"userInfo"];
    PCDLoginSession *session = [PCDLoginSession mj_objectWithKeyValues:userInfo];
    YTForgetPWDController *changePWDVC = [[YTForgetPWDController alloc]init];
    changePWDVC.session = session;
    changePWDVC.changeResultBlock = ^{
        NSArray *viewControlles = PCDUtil.getCurrentVC.navigationController.viewControllers;
        for (int i=0; i < [viewControlles count]; i++) {
            UIViewController *vc = [viewControlles objectAtIndex:i];
            if ([vc isKindOfClass:[PCDLoginController class]] || [vc isKindOfClass:[PCDQueryLoginViewController class]]) {
                [PCDUtil.getCurrentVC.navigationController popToViewController:vc animated:NO];
                return;
            }
        }
        [PCDUtil.getCurrentVC.navigationController popViewControllerAnimated:NO];
    };
    [vc.navigationController pushViewController:changePWDVC animated:YES];
    
}

@end
